feat(batch): typed backward-references deletes; rename flag to propagate_backward_references_when_unsure - #950
Conversation
…ate_backward_references_when_unsure Rename the `propagate_backward_references` field of `InsertOptions`, `DeleteOptions` and `BatchApplyOptions` to `propagate_backward_references_when_unsure` (semantics unchanged). The name says what the flag buys: when the caller does not know whether the element it displaces carries backward references, GroveDB reads it and finds out. Callers that do know can now say so per batch op: - `GroveOp::DeleteWithCascade` (sort tag 21) always reads the deleted element and runs the flagged delete's bookkeeping: every referrer chain cascades (consent via `cascade_on_update` required) and a deleted `BidirectionalReference` is de-registered from its target. - `GroveOp::DeleteWithNoBackwardsReferenceCheck` (sort tag 22) never reads it; registered references are left dangling, exactly as an unflagged live delete leaves them. Plain `Delete` keeps following the batch flag. The backward-references preprocessor gains a `flag_on` parameter: an unflagged batch carrying a cascade op runs in per-op mode, where only the cascade ops are read and planned, the other ops pay nothing extra, and only their certain effects are staged so the cascade resolves against the batch's outcome. The M4 conflict rules apply unchanged. Estimators charge the fan-out per op rather than per flag. Both ops require GROVE_V4 full batches: pre-V4 versions, partial batches and partial-batch add-on ops refuse them with `NotSupported` instead of silently degrading to a plain delete; `apply_operations_without_batching` gets the same gate. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe batch API adds typed deletes that either cascade backward-reference cleanup or skip backward-reference checks. It adds per-operation expansion and cost handling, rejects typed deletes in unsupported contexts, and renames the propagation option across code, tests, and documentation. ChangesBackward-reference delete behavior
Priority: ⬇️ Low Estimated code review effort: 4 (Complex) | ~45 minutes Merge Risk: ⚪ Minimal · up to This change adds typed batch delete behavior and renames the backward-reference propagation option. The supplied coverage indicates the supported execution, validation, version-gating, and cost paths are covered, with no remaining concrete merge-blocking risk. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…ion it carries Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #950 +/- ##
===========================================
+ Coverage 92.99% 93.05% +0.05%
===========================================
Files 327 330 +3
Lines 103297 103491 +194
===========================================
+ Hits 96065 96303 +238
+ Misses 7232 7188 -44
🚀 New features to boost your workflow:
|
…per-op-mode branches Codecov flagged the Debug labels of the two typed deletes, their _estimated_op constructors, BatchApplyOptions::as_insert_options through apply_operations_without_batching, the fresh-subtree pre-scan arms for Replace and known-new tree writes under the flag, and the RefreshReference skip in per-op mode. Each now has a test. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…atching path Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
What
Rename (breaking for 6.0.0 crate consumers).
propagate_backward_referencesonInsertOptions,DeleteOptionsandBatchApplyOptionsis nowpropagate_backward_references_when_unsure. Semantics are unchanged. The name says what the flag buys: when the caller does not know whether the element it displaces carries backward references, GroveDB reads it and finds out, then propagates or cascades accordingly.Two typed batch deletes that pin that decision per op, whatever the batch flag says:
GroveOp::DeleteWithCascade(sort tag 21): always reads the element and runs exactly the flagged delete's bookkeeping. Every referrer chain cascades, each affected reference must allowcascade_on_update, and a deletedBidirectionalReferenceis de-registered from its target.GroveOp::DeleteWithNoBackwardsReferenceCheck(sort tag 22): never reads the element. Registered references are left dangling, exactly as an unflagged live delete leaves them.Plain
Deletekeeps following the batch flag. Constructors:delete_with_cascade_op,delete_with_no_backwards_reference_check_op, plus_estimated_optwins.How
expand_backward_references_opsgainsflag_on. An unflagged batch carrying a cascade op runs the pass in per-op mode: only the cascade ops are read and planned; other ops are not read (no extra cost) and only their certain effects are staged into the overlay, so the cascade resolves against the batch's outcome. The M4 conflict rules apply unchanged. The fresh-subtree pre-scan runs only under the flag, since it reads every tree-writing op.NotSupportedrather than silently degrading to a plain delete.apply_operations_without_batchinggets the same gate.Design notes for reviewers
Deleteis free of replay concerns. The rename itself is a source-level break for consumers of the 6.0.0 crates.Testing
batch_backward_references_tests.rs: live-vs-batch root equality for both ops, de-registration when deleting a reference, consent, mixed unflagged batches (cascade op cascades while a plain delete dangles), conflict fail-closed, the without-batching path, pre-V4 and partial-batch refusals, sort-tag pins.batch_backward_references_cost_tests.rs: worst-case estimate covers an actual unflagged cascade; fan-out follows the op, not the flag, and is byte-stable pre-V4.full,estimated_costs(3453 + integration + doctests);cargo clippy --all-targets -D warningsclean on grovedb and grovedb-version.Docs: CHANGELOG (Added + BREAKING Changed),
adr/bidirectional_references.md,docs/book/src/batch-operations.md,docs/crates/grovedb.md.🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Breaking Changes
propagate_backward_references_when_unsure; behavior remains unchanged for existing operations.Documentation